package com.hairline.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hairline.bean.Footprint;
import com.hairline.bean.vo.FootprintVO;
import com.hairline.bean.vo.FootprintsVO;
import com.hairline.mapper.FootprintMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WxFootprintServiceImpl implements WxFootprintService {

    @Autowired
    FootprintMapper footprintMapper;

    @Override
    public FootprintVO footprintList(Integer page, Integer size, Integer id) {
        FootprintVO footprintVO = new FootprintVO();
        PageHelper.startPage(page, size);
        List<FootprintsVO> items = footprintMapper.footprintList(id);
        Long total = new PageInfo<>(items).getTotal();

        footprintVO.setFootprintList(items);
        footprintVO.setTotalPages(total);
        return footprintVO;
    }

    @Override
    public int footprintDelete(Integer id) {
        int i = footprintMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public void log(Footprint footprint) {
        footprintMapper.insertSelective(footprint);
    }
}
